239895
@@ -21,7 +21,6 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 
@@ -58,7 +57,7 @@
public long getTotalTime() {
   }
 
 
-  private void populateAggregateStats(HiveConf conf) {
+  private void populateAggregateStats(HiveConf conf) throws SQLException {
     int waitWindow = rawProfileConnInfo.getWaitWindow();
     int maxRetries = rawProfileConnInfo.getMaxRetries();
 
@@ -83,9 +82,10 @@
public ResultSet run(PreparedStatement stmt) throws SQLException {
 
       populateAggregateStats(result);
       getProfileStatsStmt.close();
-      rawProfileConnInfo.getConnection().close();
     } catch(Exception e) {
       LOG.error("executing error: ", e);
+    } finally {
+      HiveProfilerUtils.closeConnection(rawProfileConnInfo);
     }
   }
 
